home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 10 / AACD 10.iso / AACD / Games / MAME / src / vidhrdw / atetris.c < prev    next >
C/C++ Source or Header  |  2000-04-23  |  5KB  |  190 lines

  1. /***************************************************************************
  2.  
  3.   vidhrdw.c
  4.  
  5.   Functions to emulate the video hardware of the machine.
  6.  
  7. ***************************************************************************/
  8.  
  9. #include "driver.h"
  10. #include "vidhrdw/generic.h"
  11.  
  12. // Uncomment this if you want to see all slapstic accesses
  13. //#define LOG_SLAPSTICK
  14.  
  15.  
  16. #define BANK0 0x10000
  17. #define BANK1 0x4000
  18.  
  19. static int slapstic_primed   = 0;
  20. static int slapstic_bank     = BANK0;
  21. static int slapstic_nextbank = -1;
  22. static int slapstic_75xxcnt  = 0;
  23. static int slapstic_last60xx = 0;
  24. static int slapstic_last75xx = 0;
  25.  
  26. // I'm not sure if the information here is sufficient to figure how to the
  27. // Slapstic chip really works in this game, because BANK1 seem to be only
  28. // used rarely.
  29. //
  30. // But it seems like that reading 6090 twice in a row can select either bank.
  31. // The main difference between the 2 cases is that when BANK1 is selected,
  32. // there are 2 LD A,75XXh instructions between the 6090 reads, while when
  33. // BANK0 gets selected, there are 3.
  34.  
  35.  
  36. READ_HANDLER( atetris_slapstic_r )
  37. {
  38.     if (slapstic_nextbank != -1)
  39.     {
  40.         slapstic_bank = slapstic_nextbank;
  41.         slapstic_nextbank = -1;
  42.     }
  43.  
  44.     if ((offset & 0xff00) == 0x2000 ||
  45.         (offset & 0xff00) == 0x3500)
  46.     {
  47.         if (offset == 0x2000)
  48.         {
  49.             // Reset
  50.             slapstic_75xxcnt  = 0;
  51.             slapstic_last60xx = 0;
  52.             slapstic_primed   = 1;
  53.         }
  54.         else if (offset >= 0x3500)
  55.         {
  56.             slapstic_75xxcnt++;
  57.             slapstic_last75xx = (offset & 0xff);
  58.         }
  59.         else
  60.         {
  61.             if (slapstic_primed)
  62.             switch (offset & 0xff)
  63.             {
  64.             case 0x80:
  65.                 {
  66.                     slapstic_nextbank = BANK0;
  67. #ifdef LOG_SLAPSTICK
  68.                     logerror("Selecting Bank 0 at %04X\n", cpu_get_pc());
  69. #endif
  70.                 }
  71.                 break;
  72.  
  73.             case 0x90:
  74.                 if ((slapstic_75xxcnt == 0) ||
  75.                     (slapstic_75xxcnt == 2 && slapstic_last60xx == 0x90))
  76.                 {
  77.                     slapstic_nextbank = BANK1;
  78. #ifdef LOG_SLAPSTICK
  79.                     logerror("Selecting Bank 1 at %04X\n", cpu_get_pc());
  80. #endif
  81.                 }
  82.                 else
  83.                 {
  84.                     slapstic_nextbank = BANK0;
  85. #ifdef LOG_SLAPSTICK
  86.                     logerror("Selecting Bank 0 at %04X\n", cpu_get_pc());
  87. #endif
  88.                 }
  89.                 break;
  90.  
  91.             case 0xa0:
  92.                 if (slapstic_last60xx == 0xb0)
  93.                 {
  94.                     slapstic_nextbank = BANK1;
  95. #ifdef LOG_SLAPSTICK
  96.                     logerror("Selecting Bank 1 at %04X\n", cpu_get_pc());
  97. #endif
  98.                 }
  99.                 else
  100.                 {
  101.                     slapstic_nextbank = BANK0;
  102. #ifdef LOG_SLAPSTICK
  103.                     logerror("Selecting Bank 0 at %04X\n", cpu_get_pc());
  104. #endif
  105.                 }
  106.                 break;
  107.  
  108.             case 0xb0:
  109.                 if (slapstic_75xxcnt == 6 && slapstic_last60xx == 0xb0 &&
  110.                     slapstic_last75xx == 0x53)
  111.                 {
  112.                     slapstic_nextbank = BANK1;
  113. #ifdef LOG_SLAPSTICK
  114.                     logerror("Selecting Bank 1 at %04X\n", cpu_get_pc());
  115. #endif
  116.                 }
  117.                 else
  118.                 {
  119.                     slapstic_nextbank = BANK0;
  120. #ifdef LOG_SLAPSTICK
  121.                     logerror("Selecting Bank 0 at %04X\n", cpu_get_pc());
  122. #endif
  123.                 }
  124.                 break;
  125.  
  126.             default:
  127.                 slapstic_primed = 0;
  128.             }
  129.  
  130.             slapstic_last60xx = (offset & 0xff);
  131.             slapstic_75xxcnt = 0;
  132.         }
  133.     }
  134.     else
  135.     {
  136.         slapstic_primed = 0;
  137.     }
  138.  
  139.     return memory_region(REGION_CPU1)[slapstic_bank + offset];
  140. }
  141.  
  142.  
  143.  
  144. /***************************************************************************
  145.  
  146.   Draw the game screen in the given osd_bitmap.
  147.   Do NOT call osd_update_display() from this function, it will be called by
  148.   the main emulation engine.
  149.  
  150. ***************************************************************************/
  151. void atetris_vh_screenrefresh(struct osd_bitmap *bitmap,int full_refresh)
  152. {
  153.     int offs;
  154.  
  155.  
  156.     /* recalc the palette if necessary */
  157.     if (palette_recalc ())
  158.         memset (dirtybuffer,1,videoram_size);
  159.  
  160.  
  161.     /* for every character in the backround RAM, check if it has been modified */
  162.     /* since last time and update it accordingly. */
  163.     for (offs = 0; offs < videoram_size; offs += 2)
  164.     {
  165.         int charcode,sx,sy,color;
  166.  
  167.         if (!dirtybuffer[offs] && !dirtybuffer[offs + 1]) continue;
  168.  
  169.         dirtybuffer[offs] = dirtybuffer[offs + 1] = 0;
  170.  
  171.         sy = 8 * (offs / 128);
  172.         sx = 4 * (offs % 128);
  173.  
  174.         if (sx >= 42*8) continue;
  175.  
  176.         charcode = videoram[offs] | ((videoram[offs + 1] & 0x07) << 8);
  177.  
  178.         color = ((videoram[offs + 1] & 0xf0) >> 4);
  179.  
  180.         drawgfx(tmpbitmap,Machine->gfx[0],
  181.                 charcode,
  182.                 color,
  183.                 0,0,
  184.                 sx,sy,
  185.                 &Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  186.     }
  187.  
  188.     copybitmap(bitmap,tmpbitmap,0,0,0,0,&Machine->drv->visible_area,TRANSPARENCY_NONE,0);
  189. }
  190.